<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#assign currentMenu="video"/>
    <#include "../common/header.ftl">
    <script src="/js/plugins/jquery-bootstrap/jquery.bootstrap.min.js"></script>
    <style type="text/css">
        .modal-body {
            max-height: 750px;
            overflow-y: auto;
        }

        .modal-body img {
            width: 100%;
        }
    </style>
</head>
<body>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-lg-3">
            <#include "../common/menu.ftl">
        </div>
        <div class="col-lg-9">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-head-line">待发布视频管理</h1>
                </div>
            </div>
        <#--高级查询--->
            <form class="form-inline" id="searchForm" action="/video/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label>关键字:</label>
                    <input type="text" class="form-control" name="keyword" value="${(qo.keyword)!}"
                           placeholder="请输入标题/作者">
                </div>
                <script type="text/javascript">
                    $("#searchForm select[name='state']").val(${qo.state});
                </script>
                <button id="btn_query" class="btn btn-info">
                    <span class="glyphicon glyphicon-search"></span> 查询
                </button>
            </form>

            <table class="table table-striped table-hover">
                <tr>
                    <th>序号</th>
                    <th>封面</th>
                    <th>标题</th>
                    <th>简介</th>
                    <th>作者</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                <#list pageInfo.list as entity>
                    <tr>
                        <td>${entity_index + 1}</td>
                        <td><img src="${entity.imgUrl}" width="100"/></td>
                        <td>${entity.title}</td>
                        <td>${entity.subTitle}</td>
                        <td>${entity.user.nickName}</td>
                        <td>${entity.stateStr}</td>
                        <td>
                            <a role="button" class="btn btn-success btn-xs changeStateBtn"
                               data-json='{"id": ${entity.id}, "state": 1}'>
                                <span class="glyphicon glyphicon-ok"></span> 发布
                            </a>
                            <a role="button" class="btn btn-danger btn-xs changeStateBtn"
                               data-json='{"id": ${entity.id}, "state": -1}'>
                                <span class="glyphicon glyphicon-remove"></span> 拒绝
                            </a>
                            <a role="button" class="btn btn-primary btn-xs contentBtn" data-url="${entity.vidUrl}">
                                <span class="glyphicon glyphicon-sunglasses"></span> 查看内容
                            </a>
                        </td>
                    </tr>
                </#list>
            </table>
            <#include "../common/page.ftl">
        </div>
    </div>
</div>

<div id="videoModal" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close offVid" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">视频内容</h4>
            </div>
            <div class="modal-body">
                <video class="myVideo" width="100%" height="100%" controls="controls"></video>
            </div>
            <div class="modal-footer">
                <a role="button" class="btn btn-info offVid" data-dismiss="modal" aria-hidden="true">关闭</a>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(function () {
        //找到内容的按钮,绑定点击事件
        $(".contentBtn").click(function () {
            var url = $(this).data("url");
            $(".myVideo").attr("src",url);
            $("#videoModal").modal("show");
        });
        $(".offVid").click(function () {
            $("#videoModal").slideUp();
            $(".myVideo").trigger("pause");
        })

        //发布和拒绝的功能
        $(".changeStateBtn").click(function () {
            var json = $(this).data("json");
            console.log(json);
            $.messager.confirm("温馨提示", "亲,你却要这样吗?", function () {
                //发送ajax请求,执行更新状态
                $.post("/video/changeState.do", json, function (data) {
                    location.reload();
                });
            });
        });
    });
</script>
</body>
</html>